import 'package:flutter/material.dart';
import 'package:flutter_vant/command/overLay.dart' as overLay;
import 'package:flutter_vant/main.dart';

class VanOverlayView extends HookWidget {
  // 控制是否显示遮罩层
  final bool? show;
  // 背景颜色
  final dynamic backgroundColor;
  // 子元素
  final Widget? child;
  const VanOverlayView({Key? key, this.show, this.backgroundColor, this.child})
      : super(key: key);
  @override
  Widget build(BuildContext context) {
    bool isShow = show ?? true;

    getStyle() {
      return {
        'main': {
          CssRule.width: double.infinity,
          CssRule.height: double.infinity,
          CssRule.backgroundColor: backgroundColor,
        }
      };
    }

    return AnimatedOpacity(
        opacity: isShow ? 1 : 0,
        duration: Duration(milliseconds: 500),
        child: Frame(
          onClick: () => {},
          styles: getStyle()['main'],
          children: [child ?? Container()],
        ));
  }
}

class VanOverlay extends HookWidget {
  final dynamic backgroundColor;
  final Widget? child;
  final String keyName;
  final bool? show;
  VanOverlay(
      {this.keyName = '', this.child, this.backgroundColor, this.show = false});

  @override
  Widget build(BuildContext context) {
    return VanOverlayView(
        show: show, backgroundColor: backgroundColor, child: child);
  }
}
